Repository navigation
[CI] /review run-tests: queue targeted runs without extra Azure DevOps permissions, plus rollout fixes - #40468
Conversation
- URL-encode changed test paths before reading them at the PR head. - Inspect up to 100 changed test files; if any is skipped or unreadable, keep every AI-selected category instead of pruning it as having no enabled tests. - Move the test-merge check into Get-RunTestsMergeState and cover the stale merge, retarget, close and conflict cases. - Show the rationale when only one model produced a proposal.
The first run on dotnet/maui failed with 'The Azure DevOps request failed'. Azure rejected the build because GitHub's test-merge commit still merged a main from before the selection parameters existed. - Before queueing, check that the test-merge commit's ci-uitests.yml declares the selection parameters; if not, say the merge ref is stale and how to fix it. - Stop before either model runs when the target branch (e.g. net11) has no selection parameters, and say so on the PR. - Put Azure DevOps' own validation messages in the comment and the log.
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.sh | bash -s -- 40468Or
iex "& { $(irm https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.ps1) } 40468" |
|
Azure Pipelines: 1 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
There was a problem hiding this comment.
🟡 Changes recommended
Pipeline retrieval failures are misdiagnosed as unsupported pipelines, prompting requesters to push instead of reporting the retrieval error and providing retry guidance.
1 open issue
What changed in this PR
This PR hardens /review run-tests after its initial rollout, improving pipeline compatibility checks, test selection reliability, and requester feedback.
Changes:
- Check target-branch and test-merge pipeline support before running models or queueing selected tests.
- Encode changed-test paths and preserve selected categories when the test-file scan is incomplete.
- Surface Azure DevOps validation messages, retain single-model rationale, and add regression tests.
| File | Description |
|---|---|
.github/workflows/copilot-review-run-tests.md |
Enables unsupported-branch feedback during context collection. |
.github/workflows/copilot-review-run-tests.lock.yml |
Updates the compiled workflow to match. |
.github/scripts/RunTests.Tests.ps1 |
Adds coverage for merge checks, diagnostics, scanning, and rationale. |
.github/scripts/RunTests.Common.ps1 |
Adds validation helpers and preserves single-model rationale. |
.github/scripts/Invoke-RunTests.ps1 |
Checks merge-pipeline support, avoids incomplete-scan pruning, and improves queue errors. |
.github/scripts/Get-RunTestsContext.ps1 |
Checks branch support, encodes paths, and tracks scan completeness. |
Review effort: Balanced
|
|
||
| function Get-RunTestsPipelineAt([string]$Ref) { | ||
| $raw = & gh api -H 'Accept: application/vnd.github.raw' "repos/$Repository/contents/$($script:RunTestsPipelinePath)?ref=$Ref" 2>$null | ||
| if ($LASTEXITCODE -ne 0) { return '' } |
|
@dalexsoto stamp |
This comment has been minimized.
This comment has been minimized.
In the rollout every targeted request got 403 while full runs (no template parameters) queued. The trigger identity has 'Queue builds' on maui-pr-uitests but not 'Edit queue build configuration', which Azure DevOps requires to pass template parameters. Name the missing permission in the comment instead of 'The Azure DevOps request failed'.
Rollout on open PRs (posted
|
| Outcome | PRs | Notes |
|---|---|---|
| Full suite queued | #40418, #40290, #37337 | Both models chose the full suite; builds 1691859, 1691861, 1691867 |
| Nothing to run | #40385, #39737, #39550, #39524, #39195, #36571 | CI- or docs-only changes |
| Merge conflicts | #39487 | Expected "no test-merge commit" message |
| Targeted selection, 403 from Azure DevOps | #40369, #40344, #40288, #39935, #39655, #39495 | See below |
| Targeted selection, 400 from Azure DevOps | #40420 | Stale test-merge commit, fixed in this PR |
The 403 is fixed in this PR, with no permission change. The trigger identity has Queue builds but not Edit queue build configuration. Azure DevOps lets such an identity set boolean and fixed-value parameters, but not free-text or object ones, and selectedPlatforms and selectedCategories were objects. The pipeline now takes the selection as booleans plus one fixed-value uitest_<Category> parameter per category (see the description). The pre-merge trials passed because they were queued with a maintainer's own account.
|
/review run-tests |
|
@dalexsoto stamp |
| if ([int]$_.Exception.Response?.StatusCode -eq 403) { | ||
| # Queueing with template parameters needs 'Edit queue build configuration' on the | ||
| # pipeline, on top of 'Queue builds'; a full run without parameters needs only the latter. | ||
| $reason = "the trigger identity may queue maui-pr-uitests but not with parameters (it needs 'Edit queue build configuration' on that pipeline). $reason".Trim() |
Every targeted run on dotnet/maui got 403: Azure DevOps lets an identity with only 'Queue builds' set boolean and fixed-value runtime parameters, but free-text and object parameters need 'Edit queue build configuration'. selectedPlatforms and selectedCategories were objects. ci-uitests.yml now takes the selection as four uitestPlatform* booleans and one uitest_<Category> string per category whose value is 'none' or a fixed platform combination (android+ios, ...). It rebuilds the same platform-qualified selectedCategories list for ui-tests.yml at compile time, so the stage and matrix guards are unchanged. A selected run always carries a 'none:none' sentinel so an empty selection can never mean the full suite.
This comment has been minimized.
This comment has been minimized.
Selected UI Tests
🧪 Test selection — click to expand❌ Could not queue maui-pr-uitests: The PR was updated while tests were being selected (selected for 1ead0fa, now 0f0fe99). Comment GPT-6.1 Sol: No UI tests needed: changes only affect the /review run-tests workflow and its PowerShell helpers and unit tests. 🧪 Running — nothingNo UI tests run for this PR. ⏭️ Skipped — 77 categories, 4 platformsPlatforms not run: Android, iOS, MacCatalyst, Windows Each skipped platform and category is listed as a Skipped 🤖 Why these tests — AI rationale (GPT-6.1 Sol + Claude Opus 5.5)Each model chose independently; every test that runs was selected by at least one of them.
GPT-6.1 Sol — No UI tests needed: changes only affect the /review run-tests workflow and its PowerShell helpers and unit tests.
Claude Opus 5.5 — CI workflow/script changes for the /review run-tests automation only; no UI tests needed.
Generated by /review run-tests. A targeted run is a fast signal, not full-suite certification. |
There was a problem hiding this comment.
🟡 Changes recommended
The rebalancer leaves constrained category parameters out of sync, breaking inventory checks and targeted shard requests, while HTTP 403 handling incorrectly recommends broader permissions.
4 open issues
Review effort: Balanced
| # Queueing with template parameters needs 'Edit queue build configuration' on the | ||
| # pipeline, on top of 'Queue builds'; a full run without parameters needs only the latter. | ||
| $reason = "the trigger identity may queue maui-pr-uitests but not with parameters (it needs 'Edit queue build configuration' on that pipeline). $reason".Trim() |
| type: string | ||
| default: none | ||
| values: [none, android, ios, catalyst, windows, android+ios, android+catalyst, android+windows, ios+catalyst, ios+windows, catalyst+windows, android+ios+catalyst, android+ios+windows, android+catalyst+windows, ios+catalyst+windows, android+ios+catalyst+windows] | ||
| - name: uitest_Label |
This comment has been minimized.
This comment has been minimized.
| type: string | ||
| default: none | ||
| values: [none, android, ios, catalyst, windows, android+ios, android+catalyst, android+windows, ios+catalyst, ios+windows, catalyst+windows, android+ios+catalyst, android+ios+windows, android+catalyst+windows, ios+catalyst+windows, android+ios+catalyst+windows] | ||
| - name: uitest_Label |
There was a problem hiding this comment.
[moderate] Logic and Correctness Verification - The new constrained category inventory is not maintained by the existing rebalancer. Rebalancing Label into Label1/Label2 calls Set-ShardInfrastructure in .github/skills/rebalance-ui-test-categories/scripts/Rebalance-UITestCategories.psm1, which updates common/ui-tests.yml but never this file. Get-RunTestsInventory then accepts Label1/Label2 and Get-RunTestsTemplateParameters emits uitest_Label1/uitest_Label2, neither of which this pipeline declares, so Azure rejects those targeted runs. The new inventory-equality assertion also fails after that supported operation. Update the rebalancer to maintain both inventories and extend its regression fixture to verify them after adding/removing shards.
|
|
||
| function Get-RunTestsPipelineAt([string]$Ref) { | ||
| $raw = & gh api -H 'Accept: application/vnd.github.raw' "repos/$Repository/contents/$($script:RunTestsPipelinePath)?ref=$Ref" 2>$null | ||
| if ($LASTEXITCODE -ne 0) { return '' } |
There was a problem hiding this comment.
[moderate] Logic and Correctness Verification - A failed GitHub pipeline lookup is treated as successfully fetched unsupported YAML. On a selected run whose merge commit already supports selection, a rate limit or server error returns an empty string here; the support check then blocks queueing and tells the requester that the merge contains an older base and must be refreshed by pushing. A push cannot repair that lookup failure. Preserve retrieval success separately and report read-failure/retry guidance, with a regression case distinguishing failed retrieval from genuinely unsupported YAML.
| if ([int]$_.Exception.Response?.StatusCode -eq 403) { | ||
| # Queueing with template parameters needs 'Edit queue build configuration' on the | ||
| # pipeline, on top of 'Queue builds'; a full run without parameters needs only the latter. | ||
| $reason = "the trigger identity may queue maui-pr-uitests but not with parameters (it needs 'Edit queue build configuration' on that pipeline). $reason".Trim() |
There was a problem hiding this comment.
[moderate] Logic and Correctness Verification - Every HTTP 403 receives a permission diagnosis that does not follow from the response. A full-suite request denied Queue builds reaches this catch without any template parameters, yet its published error says the identity may queue builds and needs Edit queue build configuration. The constrained selected parameters introduced here are also intended not to require that broader permission. Preserve Azure's actual reason and use neutral access-denied guidance unless the response identifies the missing permission; cover both full and constrained selected requests instead of merely asserting that this advice appears in the source.
| $contextScript | Should -Match ([regex]::Escape('contents/$($encodedPath)?ref=')) | ||
| } | ||
|
|
||
| It 'reports an incomplete scan so trusted code does not prune' { |
There was a problem hiding this comment.
[moderate] Regression Prevention and Test Coverage - These incomplete-scan assertions only search source text, and the next test passes -Runnable $null directly rather than consuming collected context. Removing the dispatcher's $runnable = $null assignment would leave all of them satisfied while again pruning an AI-selected category enabled only by an unread changed test file. Exercise a failed file read and a change exceeding the 100-file scan limit through the collector/selection handoff, asserting that such a category survives; include a complete-scan case that still prunes an unavailable category.
PR Test Gate |
… commit (#40483) <!-- Please let the below note in for people that find this PR --> > [!NOTE] > Are you waiting for the changes in this PR to be merged? > It would be very helpful if you could [test the resulting artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from this PR and let us know in a comment if this change resolves your issue. Thank you! ### Target Branch - [x] I selected the applicable base branch using the [contribution guide](https://github.com/dotnet/maui/blob/main/.github/CONTRIBUTING.md#choose-your-pr-base-before-starting). CI workflow infrastructure, so it targets `main`. ### Description of Change Follow-up to #40468, found while testing `/review run-tests` on open PRs after it merged. `maui-pr-uitests` builds GitHub's test-merge commit (`refs/pull/N/merge`). GitHub does not refresh it when `main` moves; it waits for activity on the PR. Right after #40468 merged, every open PR's merge ref still merged an older `main` (21 merged #40305's `main`, 20 merged an even older one). Some had been stale for hours. The pipeline in those commits does not declare the new `uitest_*` parameters, so the dispatcher stopped straight away with "merges an older main". Changes: - **Wait instead of failing.** `Get-VerifiedPullRequest` now treats a merge ref whose pipeline cannot take the selection as "not ready yet". It keeps polling for up to 10 minutes, which covers a refresh GitHub is already computing. A missing merge of a new head still gives up after about 3 minutes, as before. The dispatcher job timeout goes from 15 to 25 minutes to fit. - **Check every parameter that will be sent.** `Test-RunTestsPipelineSupportsSelection` also requires each `uitest_<Category>` / `uitestPlatform*` name in the queue request. Otherwise a category added to `main` later would reach Azure as an "Unexpected parameter" 400 on PRs whose merge ref predates it. - If GitHub still hasn't refreshed after 10 minutes, the comment says so and suggests commenting again later or updating the branch. ### Validation - `RunTests.Tests.ps1` and `CopilotPipeline.Tests.ps1`: 66 passed. A new test covers parameters that are missing from the built pipeline, including regex metacharacters. - Real `/review run-tests` comments after #40468 merged, using the current `main` dispatcher (without this PR): | PR | Merge ref merges | Selection | Result | | --- | --- | --- | --- | | #40437 | new `main` (head pushed after the merge) | 9 categories, all platforms | **Queued targeted build 1692555** as the trigger identity (no 403). Azure shows `selectedRun=true`, the four platform booleans and only the 9 `uitest_*` values; only the CollectionView, CV1 and per-platform stages started | | #40418 | new `main` | full suite (both models) | Full build 1692548 | | #40369, #40344, #40288 | #40305's `main` | 5 / 4 / 2 categories | Stopped: stale merge ref | | #40420 | older `main` | 4 categories, Android | Stopped: stale merge ref | A `/review run-tests` comment, an API read and a no-op base edit did not refresh a stale merge ref within 10+ minutes; a push to the PR head refreshes it at once. Until GitHub refreshes the older PRs, they need an update or push. This PR waits for any refresh GitHub is already computing, explains the situation in the comment, and keeps a later category addition from becoming an Azure 400. Co-authored-by: Copilot CI <copilot-ci@microsoft.com>
…ures (#40485) <!-- Please let the below note in for people that find this PR --> > [!NOTE] > Are you waiting for the changes in this PR to be merged? > It would be very helpful if you could [test the resulting artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from this PR and let us know in a comment if this change resolves your issue. Thank you! ### Target Branch - [x] I selected the applicable base branch using the [contribution guide](https://github.com/dotnet/maui/blob/main/.github/CONTRIBUTING.md#choose-your-pr-base-before-starting). CI workflow infrastructure, so it targets `main`. ### Description of Change Follow-up to #40468 and #40483, found while testing `/review run-tests` on more PRs. I updated #39935's branch so its test-merge commit has the new pipeline, then commented `/review run-tests`. Both models selected 8 categories on iOS and MacCatalyst. Both attempts (19:45 and 19:57 UTC) ended with: > Could not queue maui-pr-uitests: The Azure DevOps request failed; see the workflow log. The log only shows `400 (Bad Request)`, and no build was created. - The same request validates fine in Azure's pipeline preview. - At the same moment, `review-trigger.yml` runs that use the same trigger identity failed to get a token: `AADSTS53003: Access has been blocked by Conditional Access policies. The access policy does not allow token issuance.` - So the 400 came from Microsoft Entra's token endpoint, not from Azure DevOps. - Entra's error body has `error_description`, not `message`, so `Get-RunTestsAzdoErrorText` returned nothing. Changes: - **Report Entra's reason.** `Get-RunTestsAzdoErrorText` also reads `error_description` and drops the trace and correlation ids. - **Retry the sign-in.** `Get-RunTestsAzdoToken` retries the token exchange up to 4 times, waiting 15, 30 and 45 seconds between attempts. If it still fails, it throws an error with id `RunTestsEntraSignInFailed`. - **Say what failed.** `Invoke-RunTests.ps1` turns that error into "Could not sign in to Azure DevOps: Microsoft Entra refused the token (AADSTS…). Nothing was queued; comment `/review run-tests` again later." The comment no longer suggests that Azure DevOps rejected the selection. The Conditional Access block itself is a dnceng tenant policy on the shared `AZDO_TRIGGER_CLIENT_ID` identity. It also affects `/review` through `review-trigger.yml`. It can't be fixed in this repo. ### Validation - `RunTests.Tests.ps1` and `CopilotPipeline.Tests.ps1`: 69 passed. New tests cover: - the Entra error text; - four sign-in attempts followed by the sign-in error id, with mocked HTTP calls; - the dispatcher's message for a failed sign-in. - Other real `/review run-tests` results today on `main`: - #40437 queued targeted build 1692555 with 9 categories; - #40478 (`net11`) got the "can't run on PRs that target `net11` yet" comment; - #40369 and #40344, whose test-merge commits are stale, waited 10 minutes and then explained why. Co-authored-by: Copilot CI <copilot-ci@microsoft.com>
…Entra sign-in is blocked (#40492) <!-- Please let the below note in for people that find this PR --> > [!NOTE] > Are you waiting for the changes in this PR to be merged? > It would be very helpful if you could [test the resulting artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from this PR and let us know in a comment if this change resolves your issue. Thank you! ### Target Branch - [x] I selected the applicable base branch using the [contribution guide](https://github.com/dotnet/maui/blob/main/.github/CONTRIBUTING.md#choose-your-pr-base-before-starting). CI workflow infrastructure follow-up to #40468, so it targets `main`. ### Description of Change Microsoft Entra currently refuses the federated-identity token exchange with `AADSTS53003` (Conditional Access), so `/review run-tests` cannot queue `maui-pr-uitests`. When an `AZDO_TRIGGER_PAT` repository secret exists, `Invoke-RunTests.ps1` now authenticates to Azure DevOps with it (Basic auth) instead. Without the secret nothing changes: the OIDC exchange is used. Validation: queued build 1693568 for #40437 locally with an Azure CLI token through the same script (queue path works); script parses. The PAT path itself needs the secret (scope: Build read & execute) to be exercised. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…* branch, since Entra blocks the Azure DevOps sign-in (#40504) <!-- Please let the below note in for people that find this PR --> > [!NOTE] > Are you waiting for the changes in this PR to be merged? > It would be very helpful if you could [test the resulting artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from this PR and let us know in a comment if this change resolves your issue. Thank you! ### Target Branch - [x] I selected the applicable base branch using the [contribution guide](https://github.com/dotnet/maui/blob/main/.github/CONTRIBUTING.md#choose-your-pr-base-before-starting). CI workflow infrastructure follow-up to #40468 / #40485 / #40492, so it targets `main`. ### Why `/review run-tests` still queues nothing Since about 21:00 UTC on 2026-11-20, every `/review run-tests` dispatch fails at the same step: Microsoft Entra refuses the GitHub OIDC → Azure DevOps token exchange with `AADSTS53003: Access has been blocked by Conditional Access policies`. Before that, the same code queued build 1692555. `review-trigger.yml` (`/review` → maui-copilot) fails the same way whenever it gets as far as the token step; its other runs only look green because they stop before it. #40492 added an `AZDO_TRIGGER_PAT` fallback, but no such secret exists, and using a personal PAT to get around a Conditional Access policy is not a fix we should ship. The repo has no other way to queue a build. I checked each option: | Option | Result | | --- | --- | | Federated identity (OIDC) | `AADSTS53003` on every attempt since 2026-11-20 | | `/azp run` comment from `github-actions[bot]` | Azure Pipelines answers "Commenter does not have sufficient privileges" (probe #40500) | | Queue from inside Azure DevOps with `System.AccessToken` | The job identity (public Build Service) has no *Queue builds* permission on maui-pr-uitests: permission API `false`, queue request 403 (probe #40502) | ### Description of Change `/review run-tests` now starts maui-pr-uitests through its YAML **CI trigger**, so no Azure DevOps credentials are involved: 1. `Invoke-RunTests.ps1` validates the selection as before, then uses the Git Data API to push a **dispatch commit** to `run-tests/pr<N>-<run id>`. Its tree is GitHub's test-merge tree of the PR, with `eng/pipelines` and `.github` replaced by the copies at the **target branch tip**, plus a generated `eng/pipelines/common/run-tests-request.yml`. Its parent is that target-branch commit, so the push changes no workflow. GITHUB_TOKEN is not allowed to change workflows, and its pushes don't start Actions runs. 2. `ci-uitests.yml` now builds `run-tests/*` branches. For those branches it reads the request and passes the same `selectedPlatforms` / `selectedCategories` to `common/ui-tests.yml` that the `uitest_*` parameters produced before. If the mode isn't `full`, the run is narrowed, so an unfilled request runs nothing rather than the full suite. Dispatch builds get the pull-request lanes (iOS `latest` only). 3. **Secrets:** `variables.yml` doesn't link the `MAUI` variable group (`maui-cert-password`) for `run-tests/*` builds. PR code then runs without secrets, as it does in a PR build from a fork. The pipeline YAML always comes from the target branch, never from the PR. 4. Azure Pipelines reports its checks on the dispatch commit, so a **`maui-pr-uitests (selected run)`** check on the PR head follows the build. The skipped and selection checks are unchanged. `Update-RunTestsResults.ps1` matches comments by the dispatch commit too, completes that check, and its 30-minute sweep deletes dispatch branches older than 3 days. 5. Removed: the Entra token exchange, the PAT fallback, `id-token: write`, and the template-parameter queue request. The dispatch workflow now needs `contents: write`, and the results workflow needs `checks: write` and `contents: write`. ### Validation - Ran `Invoke-RunTests.ps1` locally with this branch as `-PipelineSource`, on #40437 at `85ec75d5`, with the real GPT-6.1 Sol and Claude Opus 5.5 proposals from run 44944036321. It pushed `run-tests/pr40437-1795314808` (dispatch commit `81026002`), and **maui-pr-uitests build 1693858** started from the CI trigger about 15 s later. That build has 8 stages instead of 12, and only maui-pr-uitests built the branch. The comment was posted, and `Update-RunTestsResults.ps1` finds it by the dispatch commit. - Azure DevOps pipeline preview of the dispatch YAML: - `selected`: only the selected stages; each matrix holds only the selected categories, and the zero-tests guard is on. - `full`: all 12 stages. - the checked-in default (`none`): rejected with "no stages", never the full suite. - None of the three links the `MAUI` group. - `RunTests.Tests.ps1` and `CopilotPipeline.Tests.ps1`: 68 passed. The new tests cover: - the request encoding, and that it rejects any value that would inject YAML; - the branch naming; - the pipeline guards, including the `MAUI` group exclusion and that no other pipeline builds `run-tests/*`; - that the dispatch path uses no Azure DevOps credentials. ### For reviewers - For PRs from forks, the dispatch build runs the PR's code with the branch-build job token (public Build Service, which also has *Manage build queue*) instead of a fork PR build's read-only token. It still gets no variable-group secrets and none of the PR's pipeline YAML. If that's not acceptable, I can limit dispatch to same-repo PRs. - Restoring the federated identity (a Conditional Access exclusion for the workload identity) would also fix `/review`, which this PR does not touch. - After merge, `run-tests/*` branches appear in dotnet/maui. No ruleset, Actions workflow or other pipeline reacts to them. Co-authored-by: kubaflo <kubaflo@users.noreply.github.com>
…s permissions, plus rollout fixes (dotnet#40468) <!-- Please let the below note in for people that find this PR --> > [!NOTE] > Are you waiting for the changes in this PR to be merged? > It would be very helpful if you could [test the resulting artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from this PR and let us know in a comment if this change resolves your issue. Thank you! ### Target Branch - [x] I selected the applicable base branch using the [contribution guide](https://github.com/dotnet/maui/blob/main/.github/CONTRIBUTING.md#choose-your-pr-base-before-starting). CI workflow infrastructure follow-up to dotnet#40305, so it targets `main`. ### Description of Change Fixes found by running `/review run-tests` on open PRs after dotnet#40305 merged, plus the reviewer findings that were still open on dotnet#40305. **Found in the rollout** **1. Every targeted run was refused with 403.** Since sprint 237, Azure DevOps lets an identity with only *Queue builds* set runtime parameters whose values come from a fixed list (booleans, `values:` strings). Free-text and `object` parameters need *Edit queue build configuration*, which the trigger identity doesn't have. `selectedPlatforms` and `selectedCategories` were objects. Full-suite runs, which pass no parameters, were queued fine. `ci-uitests.yml` now takes the selection only as constrained parameters, so no permission change is needed: | Parameter | Type | Meaning | | --- | --- | --- | | `selectedRun` | boolean | A `/review run-tests` selection | | `uitestPlatformAndroid`, `…Ios`, `…Catalyst`, `…Windows` | boolean | Which platforms build and run | | `uitest_<Category>` (one per category, 77) | string, `values: [none, android, ios, …, android+ios+catalyst+windows]` | Where that category runs | At compile time it rebuilds the same platform-qualified `selectedCategories` list (`android:Button`, `ios:Label`, …) for `ui-tests.yml`, so no stage or matrix guard changed. A selected run always includes a `none:none` sentinel, so an empty selection can never fall back to "every category". A Pester test keeps the `uitest_*` list in sync with the categories in `ui-tests.yml`. **2. A stale test-merge commit returned 400.** The first run (dotnet#40420) selected `Shell1`, `Shell2` and `TitleView` on Android correctly, but the comment said only "The Azure DevOps request failed". Azure's response was: > Unexpected parameter 'selectedRun'; Unexpected parameter 'selectedPlatforms'; Unexpected parameter 'selectedCategories' GitHub's test-merge commit for that PR still merged a `main` from before dotnet#40305, so the pipeline being built had no selection parameters. GitHub refreshes those commits lazily: right after the merge, 13 of 38 `main` PRs still had a stale one. PRs targeting `net11`, `net11.0` and other branches can never be queued this way, because those branches don't have the parameters. | Change | Effect | | --- | --- | | Check the test-merge commit's `eng/pipelines/ci-uitests.yml` before queueing | A stale merge ref gets a clear message (push to the PR, then comment again) instead of a failed request | | Check the target branch in pre-activation | On a branch without the parameters, neither model runs; the PR gets a one-line comment pointing to `/azp run maui-pr-uitests` | | Show Azure DevOps' validation messages | Any other rejection says why, in the comment and the log | **Open reviewer findings from dotnet#40305** | Change | Effect | | --- | --- | | URL-encode changed test paths | A test file with `#` or `?` in its name is read correctly | | Read up to 100 changed test files; if any is skipped or unreadable, don't prune | An AI-selected category enabled only by an unread test file is no longer dropped as having no tests | | `Get-RunTestsMergeState` helper | The stale test-merge check is unit tested (old head, missing commit, retarget, close, conflict) | | Single-model rationale | When only one model answers, the comment shows its rationale instead of "No rationale provided" | ### Validation - `RunTests.Tests.ps1` and `CopilotPipeline.Tests.ps1`: 65 tests pass, including new ones for every change above. - The new helpers were checked against real data: the Azure 400 response from dotnet#40420 yields the three messages above; the pipeline check is false for dotnet#40420's stale merge commit and for `net11`, and true for `main`. - `gh aw compile --strict` succeeds. - Azure DevOps preview of this branch: | Parameters | Compiled to | | --- | --- | | none | identical to `main` (13 jobs, same matrices) | | Android `Button` | Android build + 1 Android job (`Button`) | | Android `Material3` + iOS `Label` | Material3 lane on Android, `Label` on iOS only | | Android `Shell1` | Android `Shell1` + the Shell renderer lane | | Windows `CollectionView1` | WinUI `CollectionView1` + the CV1 lane | | `Label` on all four | `Label` on each platform | | `selectedRun` with no category | no stages (never queued by the dispatcher) | | `uitest_Button: android;rm` | rejected by Azure DevOps: not a valid value | - **Not verified before merge:** the trigger identity actually queueing with these parameters. Only the default branch can use its federated credential; after merge, comment `/review run-tests` on a PR. - Rollout results are in the comments below. --------- Co-authored-by: Copilot CI <copilot-ci@microsoft.com>
… commit (dotnet#40483) <!-- Please let the below note in for people that find this PR --> > [!NOTE] > Are you waiting for the changes in this PR to be merged? > It would be very helpful if you could [test the resulting artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from this PR and let us know in a comment if this change resolves your issue. Thank you! ### Target Branch - [x] I selected the applicable base branch using the [contribution guide](https://github.com/dotnet/maui/blob/main/.github/CONTRIBUTING.md#choose-your-pr-base-before-starting). CI workflow infrastructure, so it targets `main`. ### Description of Change Follow-up to dotnet#40468, found while testing `/review run-tests` on open PRs after it merged. `maui-pr-uitests` builds GitHub's test-merge commit (`refs/pull/N/merge`). GitHub does not refresh it when `main` moves; it waits for activity on the PR. Right after dotnet#40468 merged, every open PR's merge ref still merged an older `main` (21 merged dotnet#40305's `main`, 20 merged an even older one). Some had been stale for hours. The pipeline in those commits does not declare the new `uitest_*` parameters, so the dispatcher stopped straight away with "merges an older main". Changes: - **Wait instead of failing.** `Get-VerifiedPullRequest` now treats a merge ref whose pipeline cannot take the selection as "not ready yet". It keeps polling for up to 10 minutes, which covers a refresh GitHub is already computing. A missing merge of a new head still gives up after about 3 minutes, as before. The dispatcher job timeout goes from 15 to 25 minutes to fit. - **Check every parameter that will be sent.** `Test-RunTestsPipelineSupportsSelection` also requires each `uitest_<Category>` / `uitestPlatform*` name in the queue request. Otherwise a category added to `main` later would reach Azure as an "Unexpected parameter" 400 on PRs whose merge ref predates it. - If GitHub still hasn't refreshed after 10 minutes, the comment says so and suggests commenting again later or updating the branch. ### Validation - `RunTests.Tests.ps1` and `CopilotPipeline.Tests.ps1`: 66 passed. A new test covers parameters that are missing from the built pipeline, including regex metacharacters. - Real `/review run-tests` comments after dotnet#40468 merged, using the current `main` dispatcher (without this PR): | PR | Merge ref merges | Selection | Result | | --- | --- | --- | --- | | dotnet#40437 | new `main` (head pushed after the merge) | 9 categories, all platforms | **Queued targeted build 1692555** as the trigger identity (no 403). Azure shows `selectedRun=true`, the four platform booleans and only the 9 `uitest_*` values; only the CollectionView, CV1 and per-platform stages started | | dotnet#40418 | new `main` | full suite (both models) | Full build 1692548 | | dotnet#40369, dotnet#40344, dotnet#40288 | dotnet#40305's `main` | 5 / 4 / 2 categories | Stopped: stale merge ref | | dotnet#40420 | older `main` | 4 categories, Android | Stopped: stale merge ref | A `/review run-tests` comment, an API read and a no-op base edit did not refresh a stale merge ref within 10+ minutes; a push to the PR head refreshes it at once. Until GitHub refreshes the older PRs, they need an update or push. This PR waits for any refresh GitHub is already computing, explains the situation in the comment, and keeps a later category addition from becoming an Azure 400. Co-authored-by: Copilot CI <copilot-ci@microsoft.com>
…ures (dotnet#40485) <!-- Please let the below note in for people that find this PR --> > [!NOTE] > Are you waiting for the changes in this PR to be merged? > It would be very helpful if you could [test the resulting artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from this PR and let us know in a comment if this change resolves your issue. Thank you! ### Target Branch - [x] I selected the applicable base branch using the [contribution guide](https://github.com/dotnet/maui/blob/main/.github/CONTRIBUTING.md#choose-your-pr-base-before-starting). CI workflow infrastructure, so it targets `main`. ### Description of Change Follow-up to dotnet#40468 and dotnet#40483, found while testing `/review run-tests` on more PRs. I updated dotnet#39935's branch so its test-merge commit has the new pipeline, then commented `/review run-tests`. Both models selected 8 categories on iOS and MacCatalyst. Both attempts (19:45 and 19:57 UTC) ended with: > Could not queue maui-pr-uitests: The Azure DevOps request failed; see the workflow log. The log only shows `400 (Bad Request)`, and no build was created. - The same request validates fine in Azure's pipeline preview. - At the same moment, `review-trigger.yml` runs that use the same trigger identity failed to get a token: `AADSTS53003: Access has been blocked by Conditional Access policies. The access policy does not allow token issuance.` - So the 400 came from Microsoft Entra's token endpoint, not from Azure DevOps. - Entra's error body has `error_description`, not `message`, so `Get-RunTestsAzdoErrorText` returned nothing. Changes: - **Report Entra's reason.** `Get-RunTestsAzdoErrorText` also reads `error_description` and drops the trace and correlation ids. - **Retry the sign-in.** `Get-RunTestsAzdoToken` retries the token exchange up to 4 times, waiting 15, 30 and 45 seconds between attempts. If it still fails, it throws an error with id `RunTestsEntraSignInFailed`. - **Say what failed.** `Invoke-RunTests.ps1` turns that error into "Could not sign in to Azure DevOps: Microsoft Entra refused the token (AADSTS…). Nothing was queued; comment `/review run-tests` again later." The comment no longer suggests that Azure DevOps rejected the selection. The Conditional Access block itself is a dnceng tenant policy on the shared `AZDO_TRIGGER_CLIENT_ID` identity. It also affects `/review` through `review-trigger.yml`. It can't be fixed in this repo. ### Validation - `RunTests.Tests.ps1` and `CopilotPipeline.Tests.ps1`: 69 passed. New tests cover: - the Entra error text; - four sign-in attempts followed by the sign-in error id, with mocked HTTP calls; - the dispatcher's message for a failed sign-in. - Other real `/review run-tests` results today on `main`: - dotnet#40437 queued targeted build 1692555 with 9 categories; - dotnet#40478 (`net11`) got the "can't run on PRs that target `net11` yet" comment; - dotnet#40369 and dotnet#40344, whose test-merge commits are stale, waited 10 minutes and then explained why. Co-authored-by: Copilot CI <copilot-ci@microsoft.com>
…Entra sign-in is blocked (dotnet#40492) <!-- Please let the below note in for people that find this PR --> > [!NOTE] > Are you waiting for the changes in this PR to be merged? > It would be very helpful if you could [test the resulting artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from this PR and let us know in a comment if this change resolves your issue. Thank you! ### Target Branch - [x] I selected the applicable base branch using the [contribution guide](https://github.com/dotnet/maui/blob/main/.github/CONTRIBUTING.md#choose-your-pr-base-before-starting). CI workflow infrastructure follow-up to dotnet#40468, so it targets `main`. ### Description of Change Microsoft Entra currently refuses the federated-identity token exchange with `AADSTS53003` (Conditional Access), so `/review run-tests` cannot queue `maui-pr-uitests`. When an `AZDO_TRIGGER_PAT` repository secret exists, `Invoke-RunTests.ps1` now authenticates to Azure DevOps with it (Basic auth) instead. Without the secret nothing changes: the OIDC exchange is used. Validation: queued build 1693568 for dotnet#40437 locally with an Azure CLI token through the same script (queue path works); script parses. The PAT path itself needs the secret (scope: Build read & execute) to be exercised. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…* branch, since Entra blocks the Azure DevOps sign-in (dotnet#40504) <!-- Please let the below note in for people that find this PR --> > [!NOTE] > Are you waiting for the changes in this PR to be merged? > It would be very helpful if you could [test the resulting artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from this PR and let us know in a comment if this change resolves your issue. Thank you! ### Target Branch - [x] I selected the applicable base branch using the [contribution guide](https://github.com/dotnet/maui/blob/main/.github/CONTRIBUTING.md#choose-your-pr-base-before-starting). CI workflow infrastructure follow-up to dotnet#40468 / dotnet#40485 / dotnet#40492, so it targets `main`. ### Why `/review run-tests` still queues nothing Since about 21:00 UTC on 2026-11-20, every `/review run-tests` dispatch fails at the same step: Microsoft Entra refuses the GitHub OIDC → Azure DevOps token exchange with `AADSTS53003: Access has been blocked by Conditional Access policies`. Before that, the same code queued build 1692555. `review-trigger.yml` (`/review` → maui-copilot) fails the same way whenever it gets as far as the token step; its other runs only look green because they stop before it. dotnet#40492 added an `AZDO_TRIGGER_PAT` fallback, but no such secret exists, and using a personal PAT to get around a Conditional Access policy is not a fix we should ship. The repo has no other way to queue a build. I checked each option: | Option | Result | | --- | --- | | Federated identity (OIDC) | `AADSTS53003` on every attempt since 2026-11-20 | | `/azp run` comment from `github-actions[bot]` | Azure Pipelines answers "Commenter does not have sufficient privileges" (probe dotnet#40500) | | Queue from inside Azure DevOps with `System.AccessToken` | The job identity (public Build Service) has no *Queue builds* permission on maui-pr-uitests: permission API `false`, queue request 403 (probe dotnet#40502) | ### Description of Change `/review run-tests` now starts maui-pr-uitests through its YAML **CI trigger**, so no Azure DevOps credentials are involved: 1. `Invoke-RunTests.ps1` validates the selection as before, then uses the Git Data API to push a **dispatch commit** to `run-tests/pr<N>-<run id>`. Its tree is GitHub's test-merge tree of the PR, with `eng/pipelines` and `.github` replaced by the copies at the **target branch tip**, plus a generated `eng/pipelines/common/run-tests-request.yml`. Its parent is that target-branch commit, so the push changes no workflow. GITHUB_TOKEN is not allowed to change workflows, and its pushes don't start Actions runs. 2. `ci-uitests.yml` now builds `run-tests/*` branches. For those branches it reads the request and passes the same `selectedPlatforms` / `selectedCategories` to `common/ui-tests.yml` that the `uitest_*` parameters produced before. If the mode isn't `full`, the run is narrowed, so an unfilled request runs nothing rather than the full suite. Dispatch builds get the pull-request lanes (iOS `latest` only). 3. **Secrets:** `variables.yml` doesn't link the `MAUI` variable group (`maui-cert-password`) for `run-tests/*` builds. PR code then runs without secrets, as it does in a PR build from a fork. The pipeline YAML always comes from the target branch, never from the PR. 4. Azure Pipelines reports its checks on the dispatch commit, so a **`maui-pr-uitests (selected run)`** check on the PR head follows the build. The skipped and selection checks are unchanged. `Update-RunTestsResults.ps1` matches comments by the dispatch commit too, completes that check, and its 30-minute sweep deletes dispatch branches older than 3 days. 5. Removed: the Entra token exchange, the PAT fallback, `id-token: write`, and the template-parameter queue request. The dispatch workflow now needs `contents: write`, and the results workflow needs `checks: write` and `contents: write`. ### Validation - Ran `Invoke-RunTests.ps1` locally with this branch as `-PipelineSource`, on dotnet#40437 at `85ec75d5`, with the real GPT-6.1 Sol and Claude Opus 5.5 proposals from run 44944036321. It pushed `run-tests/pr40437-1795314808` (dispatch commit `81026002`), and **maui-pr-uitests build 1693858** started from the CI trigger about 15 s later. That build has 8 stages instead of 12, and only maui-pr-uitests built the branch. The comment was posted, and `Update-RunTestsResults.ps1` finds it by the dispatch commit. - Azure DevOps pipeline preview of the dispatch YAML: - `selected`: only the selected stages; each matrix holds only the selected categories, and the zero-tests guard is on. - `full`: all 12 stages. - the checked-in default (`none`): rejected with "no stages", never the full suite. - None of the three links the `MAUI` group. - `RunTests.Tests.ps1` and `CopilotPipeline.Tests.ps1`: 68 passed. The new tests cover: - the request encoding, and that it rejects any value that would inject YAML; - the branch naming; - the pipeline guards, including the `MAUI` group exclusion and that no other pipeline builds `run-tests/*`; - that the dispatch path uses no Azure DevOps credentials. ### For reviewers - For PRs from forks, the dispatch build runs the PR's code with the branch-build job token (public Build Service, which also has *Manage build queue*) instead of a fork PR build's read-only token. It still gets no variable-group secrets and none of the PR's pipeline YAML. If that's not acceptable, I can limit dispatch to same-repo PRs. - Restoring the federated identity (a Conditional Access exclusion for the workload identity) would also fix `/review`, which this PR does not touch. - After merge, `run-tests/*` branches appear in dotnet/maui. No ruleset, Actions workflow or other pipeline reacts to them. Co-authored-by: kubaflo <kubaflo@users.noreply.github.com>

Note
Are you waiting for the changes in this PR to be merged?
It would be very helpful if you could test the resulting artifacts from this PR and let us know in a comment if this change resolves your issue. Thank you!
Target Branch
CI workflow infrastructure follow-up to #40305, so it targets
main.Description of Change
Fixes found by running
/review run-testson open PRs after #40305 merged, plus the reviewer findings that were still open on #40305.Found in the rollout
1. Every targeted run was refused with 403. Since sprint 237, Azure DevOps lets an identity with only Queue builds set runtime parameters whose values come from a fixed list (booleans,
values:strings). Free-text andobjectparameters need Edit queue build configuration, which the trigger identity doesn't have.selectedPlatformsandselectedCategorieswere objects. Full-suite runs, which pass no parameters, were queued fine.ci-uitests.ymlnow takes the selection only as constrained parameters, so no permission change is needed:selectedRun/review run-testsselectionuitestPlatformAndroid,…Ios,…Catalyst,…Windowsuitest_<Category>(one per category, 77)values: [none, android, ios, …, android+ios+catalyst+windows]At compile time it rebuilds the same platform-qualified
selectedCategorieslist (android:Button,ios:Label, …) forui-tests.yml, so no stage or matrix guard changed. A selected run always includes anone:nonesentinel, so an empty selection can never fall back to "every category". A Pester test keeps theuitest_*list in sync with the categories inui-tests.yml.2. A stale test-merge commit returned 400.
The first run (#40420) selected
Shell1,Shell2andTitleViewon Android correctly, but the comment said only "The Azure DevOps request failed". Azure's response was:GitHub's test-merge commit for that PR still merged a
mainfrom before #40305, so the pipeline being built had no selection parameters. GitHub refreshes those commits lazily: right after the merge, 13 of 38mainPRs still had a stale one. PRs targetingnet11,net11.0and other branches can never be queued this way, because those branches don't have the parameters.eng/pipelines/ci-uitests.ymlbefore queueing/azp run maui-pr-uitestsOpen reviewer findings from #40305
#or?in its name is read correctlyGet-RunTestsMergeStatehelperValidation
RunTests.Tests.ps1andCopilotPipeline.Tests.ps1: 65 tests pass, including new ones for every change above.The new helpers were checked against real data: the Azure 400 response from [Android] [Shell] Fix toolbar title and appearance after tab navigation #40420 yields the three messages above; the pipeline check is false for [Android] [Shell] Fix toolbar title and appearance after tab navigation #40420's stale merge commit and for
net11, and true formain.gh aw compile --strictsucceeds.Azure DevOps preview of this branch:
main(13 jobs, same matrices)ButtonButton)Material3+ iOSLabelLabelon iOS onlyShell1Shell1+ the Shell renderer laneCollectionView1CollectionView1+ the CV1 laneLabelon all fourLabelon each platformselectedRunwith no categoryuitest_Button: android;rmNot verified before merge: the trigger identity actually queueing with these parameters. Only the default branch can use its federated credential; after merge, comment
/review run-testson a PR.Rollout results are in the comments below.